package restlet;

import model.KategorijaPovlastice;
import model.Mesto;
import model.Util;
import model.Version;
import model.VrstaPrevoza;

import org.restlet.resource.ServerResource;

import restlet.interfaces.VersionResourceI;

public class VersionResource extends ServerResource implements VersionResourceI{

	@Override
	public Integer getVersion(Integer pType) {
		
		final String MESTO = Mesto.class.getSimpleName();
		final String KatPovl = KategorijaPovlastice.class.getSimpleName();
		final String VrPrev = VrstaPrevoza.class.getSimpleName();
		
		String className = null;
		int type = pType;
		
		if(type == 1){
			className = MESTO;
		}
			
		if(type == 2){
			className = KatPovl;
		}

		if(type == 3){
			className = VrPrev;
		}
		
		getLogger().warning("Verzija za: " + className);
		
		getLogger().warning("PlaceResource123,uzimamo verziju...");
		
		Version vMesta = Util.getEnityByFieldEqualsValue(Version.class,
				"imeKlase", className);
		Integer iVrednost = Integer.valueOf(vMesta.getVrednost());
		return iVrednost;
	}
}
